package com.taotao.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.taotao.manage.pojo.ItemDesc;
import com.taotao.web.pojo.ItemVO;
import com.taotao.web.service.ItemDescService;
import com.taotao.web.service.ItemService;

@Controller
@RequestMapping("item")
public class ItemController {
	
	@Autowired
	private ItemService itemService;
	
	@Autowired
	private ItemDescService itemDescService;

	/**
	 * 跳转到商品详情页
	 * @param itemId
	 * @param model
	 * @return
	 */
	@GetMapping("{itemId}")
	public String toItem(@PathVariable("itemId")Long itemId, Model model){
		// 查询商品详情
		ItemVO item = this.itemService.queryItemById(itemId);
		// 传递参数
		model.addAttribute("item", item);
		
		// 查询商品描述信息
		ItemDesc itemDesc = this.itemDescService.queryItemDescById(itemId);
		model.addAttribute("itemDesc", itemDesc);
		// 跳转到详情页
		return "item";
	}
}
